﻿#include "MeshData.h"


namespace Base {
	void MeshData::InitFromIndexedTriangleList(const IndexedTriangleList& t) {
		m_posVec = t.vertices;
		m_indicesVec = t.indices;
	}

	void MeshData::InitFromIndexedTriangleList(const IndexedTriangleList& t, const Vec4& color) {
		m_posVec = t.vertices;
		m_indicesVec = t.indices;

		// 产生颜色数据
		unsigned short maxIndex = 0;
		for (size_t i = 0; i < m_indicesVec.size(); i++)
		{
			if (m_indicesVec[i] > maxIndex)
			{
				maxIndex = m_indicesVec[i];
			}
		}

		m_colorVec.clear();
		for (size_t i = 0; i <= maxIndex; i++)
		{
			m_colorVec.push_back(color);
		}
	}
}